import 'package:flutter_app/constants/route_names.dart';
import 'package:flutter_app/providers/auth_provider.dart';
import 'package:go_router/go_router.dart';
// page
import 'package:flutter_app/pages/error.dart';
import 'package:flutter_app/pages/home.dart';

class AddRouter {
  final AuthProvider authProvider;

  AddRouter(this.authProvider);

  late final GoRouter router = GoRouter(
    // 初始化路由
    initialLocation: '/',
    // 错误页面
    errorBuilder: (context, state) => const NotFoundPage(),
    // 路由守卫
    // redirect: (BuildContext context, GoRouterState, state) {
    //   return null;
    // }
    routes: _routes
  );

  List<GoRoute> get _routes => [
    GoRoute(
      path: RouteNames.home,
      name: RouteNames.home,
      builder: (context, state) => HomePage(),
    ),
  ];
}
